package com.older.wptsb.controller.family;


import com.older.wptsb.domain.dto.UserElderRelDTO;
import com.older.wptsb.domain.po.RequireRole;
import com.older.wptsb.domain.po.UserRole;
import com.older.wptsb.domain.vo.AlertLogVO;
import com.older.wptsb.domain.vo.ElderVO;
import com.older.wptsb.domain.vo.HealthDataVO;
import com.older.wptsb.service.FamilyElderService;
import com.older.wptsb.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/family")
public class FamilyController {

    @Resource
    private FamilyElderService familyElderService;
    @RequireRole({UserRole.ROLE_FAMILY})
    @GetMapping("/getElderHealthData1")
    public Result<List<HealthDataVO>> getElderHealthData() {
        List<HealthDataVO> healthDataVO = familyElderService.getElderHealthData();
        return Result.success(healthDataVO);
    }
    @RequireRole({UserRole.ROLE_FAMILY})
    @GetMapping("/getElderHealthData")
    public Result<List<HealthDataVO>> getElderHealthData(@RequestParam String elderId) {
        List<HealthDataVO> healthDataVO = familyElderService.getElderHealthData(elderId);
        return Result.success(healthDataVO);
    }
    @PostMapping("/bindElder")
    @RequireRole({UserRole.ROLE_FAMILY})
    public Result<String> bindElder(@RequestBody UserElderRelDTO userElderRelDTO) {
        familyElderService.bindElder(userElderRelDTO);
        return Result.success("绑定成功");
    }
    @GetMapping("/alertElder")
    @RequireRole({UserRole.ROLE_FAMILY})
    public Result<List<AlertLogVO>> alertElder() {
        List<AlertLogVO> alertLogVO = familyElderService.alertElder();
        return Result.success(alertLogVO);
    }
    @GetMapping("/getElderList")
    @RequireRole({UserRole.ROLE_FAMILY})
    public Result<List<ElderVO>> getElderList() {
        List<ElderVO> elderList = familyElderService.getElderList();
        return Result.success(elderList);
    }
}
